<template>
  <div class="container-pt">
    <van-nav-bar left-arrow  @click-left="$router.back()" fixed title="列表"/>
    <van-tabs v-model="active" animated swipeable>
      <van-tab v-for="item in allCateList" :key="item.id" >
        <template #title> <van-icon name="more-o" /> {{item.catename}} </template>
         <article-list :cateId="item.id" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import articleList from '@/components/article-list.vue'
import { indexApi } from "../api";
export default {
  components: { articleList },
  data() {
    return {
      active:0,
      currentCateId:'',  // 当前的分类ID
      allCateList:[] // 所有分类
    };
  },
  created () {
     this.active = this.$route.query.idx * 1
     this.currentCateId = this.$route.query.id 
    //  获取顶部的分类
    this.getAllCateList()
  },
  methods: {
    async getAllCateList() {
      const res = await indexApi();
      this.allCateList = res.data.data.allCate;
    }
  },
};
</script>

<style>

</style>